﻿using System;
using System.Windows.Input;

namespace NormalGsearch
{
    class StartSearchCommand : ICommand
    {
        private NormalGSearchViewModel viewModel;
        
        public event EventHandler CanExecuteChanged;

        public StartSearchCommand(NormalGSearchViewModel viewModel)
        {
            this.viewModel = viewModel;            
        }

        public void Execute(object parameter)
        {
            viewModel.OnStartSearchRequested();
        }

        public bool CanExecute(object parameter)
        {
            return true;
            
            // TBD: integrate this            
            // return (viewModel.Password != null && viewModel.Username != null
            // && viewModel.Password.Length > 0 && viewModel.Username.Length > 0);                         
        }

        private void HandleCommandActivationChange(object sender, EventArgs e)
        {
            if (CanExecuteChanged != null)
            {
                CanExecuteChanged(this, EventArgs.Empty);                
            }
        }          
    }
}
